package com.atguigu.gulimall.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.gulimall.product.entity.McarouselEntity;
import com.atguigu.gulimall.product.service.McarouselService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 *
 *
 * @author cpc
 * @email 1728980597@qq.com
 * @date 2022-04-06 12:49:35
 */
@RestController
@RequestMapping("product/mcarousel")
public class McarouselController {
    @Autowired
    private McarouselService mcarouselService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mcarouselService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{carouselId}")
    public R info(@PathVariable("carouselId") Integer carouselId){
		McarouselEntity mcarousel = mcarouselService.getById(carouselId);

        return R.ok().put("mcarousel", mcarousel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody McarouselEntity mcarousel){
		mcarouselService.save(mcarousel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody McarouselEntity mcarousel){
		mcarouselService.updateById(mcarousel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] carouselIds){
		mcarouselService.removeByIds(Arrays.asList(carouselIds));

        return R.ok();
    }

}
